namespace ColladaDotNet.OpenTKMapping
{
	public abstract class DocmentLibraryCollection<P,T>:CollectionWithIds<P> where P:DocumentLibraryElement<T>, new() where T:ColladaXmlNode
	{
		private readonly Document document;
		public DocmentLibraryCollection(Document document)
		{
			this.document = document;
		}
		public override void Add(P item)
		{
			item.Document = document;
			base.Add(item);
		}
		public virtual void Add(T visual_scene)
		{
			string id = visual_scene.GetId();
			var res = CreateElement(visual_scene);
			res.Id = id;
			Add(res);
			res.Load(visual_scene);
		}

		protected virtual P CreateElement(ColladaXmlNode data)
		{
			return (P)document.CreateElement(data);
		}

		protected override string GetIdOf(P item)
		{
			return item.Id;
		}
	}
}